using UnityEngine;
using UnityEngine.UI;

namespace WolfCarol.AvgToolkit.UI
{
    [RequireComponent(typeof(Button))]
    public class ShortcutBind : MonoBehaviour
    {
        [SerializeField] private KeyCode m_keyCode;

        private Button m_button;

        private void Awake()
        {
            m_button = GetComponent<Button>();
        }

        private void Update()
        {
            if (m_button.enabled && m_button.interactable)
            {
                if (Input.GetKeyDown(m_keyCode))
                {
                    m_button.onClick?.Invoke();
                }
            }
        }
    }
}

